package com.wu.cloud.account.api;

import bean.PeskResponseEntity;
import bean.vo.UserAddVO;
import bean.vo.UserQueryVO;
import com.wu.cloud.account.service.AdminUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author xwu36
 */
@RestController
@RequestMapping("/admin")
public class AdminUsersApi {
    @Autowired
    AdminUserService adminUserService;

    @GetMapping("/user/list")
    public PeskResponseEntity adminUserList(UserQueryVO userQueryVO) {
        return adminUserService.getUserListByAdmin(userQueryVO);
    }

    @PostMapping("/user/add")
    public PeskResponseEntity adminAddUser(@RequestBody UserAddVO userVO) {
        return adminUserService.addUserByAdmin(userVO);
    }

    @DeleteMapping("/user/disable/{uid}")
    public PeskResponseEntity adminDisableUser(@PathVariable String uid) {
        return adminUserService.disableUserByAdmin(uid);
    }

    @PostMapping("/user/update/{uid}")
    public PeskResponseEntity adminUpdateUser(@PathVariable String uid, @RequestBody UserAddVO userAddVO) {
        return adminUserService.updateUserByAdmin(userAddVO, uid);
    }
}
